
*************************************************************************
*  Creates combined Census data for Ukraine and Belarus
*  Displays summary statistics in Table 6 and runs regressions in Table 7
*  Data source:  IPUMS International
*************************************************************************

clear
# delimit ;
version 11;
capture log close;
set more 1;
log using table6and7.log, replace;

*  Creating data for Belarus 1999;
use belarusf1999;
replace chborn=. if chborn==98 | chborn==99;
gen nokids=0;
replace nokids=1 if chborn==0;
keep if byear >=1915 & byear <=1941;
gen single=0;
replace single=1 if marst==1;

collapse chborn nokids single urban age (count) nobs=sex, by(region byear);

gen regno=116 if region==1;
replace regno=117 if region==2;
replace regno=118 if region==3;
replace regno=119 if region==4;
replace regno=120 if region==5; /*  Region 5 is City of Minsk */
replace regno=121 if region==6; /*  Region 6 is Minskaya oblast */
replace regno=122 if region==7;

drop region;
gen rep=1;
sort regno byear;
save temp, replace;
clear;


*  Creating data for Ukraine 2001;
use ukrainef2001;
replace chborn=. if chborn==98 | chborn==99;
gen nokids=0;
replace nokids=1 if chborn==0;
keep if byear >=1915 & byear <=1941;
gen single=0;
replace single=1 if marst==1;

collapse chborn nokids single urban age (count) nobs=sex, by(region byear);

gen regno=99 if region==1;
replace regno=90 if region==5;
replace regno=91 if region==7;
replace regno=92 if region==12;
replace regno=106 if region==14;
replace regno=93 if region==18;
replace regno=94 if region==21;
replace regno=95 if region==23;
replace regno=107 if region==26;
replace regno=97 if region==32;
replace regno=98 if region==35;
replace regno=100 if region==44;
replace regno=101 if region==46;
replace regno=102 if region==48;
replace regno=103 if region==51;
replace regno=104 if region==53;
replace regno=105 if region==56;
replace regno=108 if region==59;
replace regno=109 if region==61;
replace regno=110 if region==63;
replace regno=111 if region==65;
replace regno=112 if region==68;
replace regno=113 if region==71;
replace regno=115 if region==73;
replace regno=114 if region==74;
replace regno=96 if region==80;
replace regno=99 if region==85;

drop region;
gen rep=2;
sort regno byear;

append using temp;
sort regno byear;

*  merging in republic-level sex ratios;
merge m:1 regno byear using sexratios_ussr;

gen popm=popmu+popmr;
gen lnpopm=log(popm);
gen lnpopmu=log(popmu);
gen lnpopmr=log(popmr);
replace lnpopm=lnpopmu if regno==96 | regno==120;  /* Minsk and Kiev */

gen time=1942-byear;

*  Table 6 Summary statistics;
sum age sr10a chborn nokids single urban nobs [aw=nobs];

*  Table 7 regressions (top panel);
*  Belarus and Ukraine;
reg chborn sr10a lnpopm urban i.byear i.regno i.regno#c.time [aw=nobs], cluster(regno);
reg nokids sr10a lnpopm urban i.byear i.regno i.regno#c.time [aw=nobs], cluster(regno);
reg single sr10a lnpopm urban i.byear i.regno i.regno#c.time [aw=nobs], cluster(regno);
clear;


*  Using sex ratio in birthplace;
*  Belarus 1999;
use belarusf1999;
replace chborn=. if chborn==98 | chborn==99;
gen nokids=0;
replace nokids=1 if chborn==0;
keep if byear >=1915 & byear <=1941;
gen single=0;
replace single=1 if marst==1;

gen birthplace=116 if bplace==1;
replace birthplace=117 if bplace==2;
replace birthplace=118 if bplace==3;
replace birthplace=119 if bplace==4;
replace birthplace=120 if bplace==5; /*  Region 5 is City of Minsk */
replace birthplace=121 if bplace==6; /*  Region 6 is Minskaya oblast */
replace birthplace=122 if bplace==7;
replace birthplace=2409 if bplace==31;
replace birthplace=3709 if bplace==51;
replace birthplace=4209 if bplace==233;
replace birthplace=2209 if bplace==268;
replace birthplace=1900 if bplace==398;
replace birthplace=3309 if bplace==417;
replace birthplace=3109 if bplace==428;
replace birthplace=2609 if bplace==440;
replace birthplace=2809 if bplace==498;
replace birthplace=1100 if bplace==643;
replace birthplace=3509 if bplace==762;
replace birthplace=3900 if bplace==795;
replace birthplace=1300 if bplace==804;
replace birthplace=1700 if bplace==860;

sort birthplace byear;
ren region regionbel;
save temp, replace;
clear;
use sexratios_ussr;
ren regno birthplace;
sort birthplace byear;
*  merging in republic-level sex ratios;
merge 1:m birthplace byear using temp;
tab _merge;

gen popm=popmu+popmr;
gen lnpopm=log(popm);
gen lnpopmu=log(popmu);
gen lnpopmr=log(popmr);
replace lnpopm=lnpopmu if birthplace==120;

collapse sr10a chborn nokids single urban lnpop* age (count) nobs=sex, by(birthplace byear);

gen rep=1;
sort birthplace byear;
save temp, replace;
clear;


*  Creating data for Ukraine 2001;
use ukrainef2001;
replace chborn=. if chborn==98 | chborn==99;
gen nokids=0;
replace nokids=1 if chborn==0;
keep if byear >=1915 & byear <=1941;
gen single=0;
replace single=1 if marst==1;

gen birthplace=99 if bplace==1;
replace birthplace=90 if bplace==5;
replace birthplace=91 if bplace==7;
replace birthplace=92 if bplace==12;
replace birthplace=106 if bplace==14;
replace birthplace=93 if bplace==18;
replace birthplace=94 if bplace==21;
replace birthplace=95 if bplace==23;
replace birthplace=107 if bplace==26;
replace birthplace=97 if bplace==32;
replace birthplace=98 if bplace==35;
replace birthplace=100 if bplace==44;
replace birthplace=101 if bplace==46;
replace birthplace=102 if bplace==48;
replace birthplace=103 if bplace==51;
replace birthplace=104 if bplace==53;
replace birthplace=105 if bplace==56;
replace birthplace=108 if bplace==59;
replace birthplace=109 if bplace==61;
replace birthplace=110 if bplace==63;
replace birthplace=111 if bplace==65;
replace birthplace=112 if bplace==68;
replace birthplace=113 if bplace==71;
replace birthplace=115 if bplace==73;
replace birthplace=114 if bplace==74;
replace birthplace=96 if bplace==80;
replace birthplace=99 if bplace==85;
replace birthplace=2409 if bplace==121;
replace birthplace=1500 if bplace==122;
replace birthplace=3709 if bplace==123;
replace birthplace=2209 if bplace==124;
replace birthplace=4209 if bplace==125;
replace birthplace=1900 if bplace==126;
replace birthplace=3309 if bplace==127;
replace birthplace=3109 if bplace==128;
replace birthplace=2609 if bplace==129;
replace birthplace=2809 if bplace==140;
replace birthplace=1100 if bplace==141;
replace birthplace=3509 if bplace==142;
replace birthplace=3900 if bplace==143;
replace birthplace=1700 if bplace==144;

sort birthplace byear;
ren region regionukr;
save temp2, replace;

use sexratios_ussr;
ren regno birthplace;
sort birthplace byear;
merge 1:m birthplace byear using temp2;
tab _merge;

gen popm=popmu+popmr;
gen lnpopm=log(popm);
gen lnpopmu=log(popmu);
gen lnpopmr=log(popmr);
replace lnpopm=lnpopmu if birthplace==96 | birthplace==120;  /* Minsk and Kiev */

collapse sr10a chborn nokids single urban lnpop* age (count) nobs=sex, by(birthplace byear);
gen rep=2;
sort birthplace byear;
append using temp;
gen time=1942-byear;

*  Table 7 regressions (bottom panel);
*  Belarus and Ukraine;
reg chborn sr10a lnpopm urban i.byear i.birthplace i.birthplace#c.time [aw=nobs], cluster(birthplace);
reg nokids sr10a lnpopm urban i.byear i.birthplace i.birthplace#c.time [aw=nobs], cluster(birthplace);
reg single sr10a lnpopm urban i.byear i.birthplace i.birthplace#c.time [aw=nobs], cluster(birthplace);

log close;


